<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@page import="utility.connections"%>
<script type="text/javascript">
<!--

function validate(frm)
	{
		alert(frm.codice.value);
		return false;
		
	}
	
	function pickfor(formname)
	{
		forms[formname].cmb
	}
	
	function pickcat()
	{
	
	}
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>NUOVA STANZA</title>
<link href="../../layout.css" rel="stylesheet" type="text/css" media="screen" />
</head>

<body>
<table width="700" height="422" border="0" align="center">
  <tr>
    <td align="center" valign="middle">&nbsp;</td>
  </tr>
  <tr>
    <td height="257" align="center" valign="top"><table width="112%" border="0">
      <tr>
        <td colspan="4" align="center"><div align="left">
          <p class="style3">
          
          <%  
		
			if (session.getAttribute("user")==null)
			response.sendRedirect("loginerr.jsp");
			
			else
			{
	
			String user = session.getAttribute("user").toString();
			String type = session.getAttribute("type").toString();
			String matr = session.getAttribute("matricola").toString();
			String nome = session.getAttribute("nome").toString();
			String cogn = session.getAttribute("cognome").toString();
			
			out.println("Benvenuto " + user);
			}
		%>
		  </p>
        </div></td>
        </tr>
      <tr>
        <td colspan="4" class="style2"><p align="center"><strong>Inserisci i dati del bene </strong></p></td>
        </tr>
	  <form  name = "frmBene" method="post" onsubmit="return validate(this);">
	  <tr>
        <td width="8%" rowspan="14" class="style1">&nbsp;</td>
        <td class="style2"><div align="right">numero inventario:</div></td>
        <td class="style2"><input type="text" name="codice" value="" width="300" disabled="disabled"/></td>
        <td width="27%" rowspan="14" class="style1"><select name="lstValues" size = "20" >
          <option>Seleziona dall'elenco</option>
        </select>        </td>
      </tr>
      <tr>
        <td class="style2"><div align="right">numero seriale: </div></td>
        <td class="style2"><input type="text" name="denominazione" value="" width="300" disabled="disabled"/></td>
        </tr>
      <tr>
        <td class="style2"><div align="right">importo:</div></td>
        <td class="style2"><input type="text" name="posizione" value="" width="300"/></td>
        </tr>
      <tr>
        <td width="18%" class="style2"><div align="right">data acquisto:</div></td>
        <td width="47%" class="style2"><input type="text" name="note" value="" width="100" /> (DD/MM/YYYY)</td>
        </tr>
      <tr>
        <td width="18%" class="style2"><div align="right">garanzia:</div></td>
        <td class="style2"><input type="checkbox" name="chkgar" value="checkbox"></td>
      </tr>
      <tr>
        <td width="18%" class="style2"><div align="right">data attivazione:</div></td>
        <td class="style2"><input type="text" name="note2" value="" width="100" /> (DD/MM/YYYY) </td>
      </tr>
      <tr>
        <td width="18%" class="style2"><div align="right">data scadenza:</div></td>
        <td class="style2"><input type="text" name="note3" value="" width="100" /> (DD/MM/YYYY) </td>
      </tr>
      <tr>
        <td width="18%" class="style2"><div align="right">conforme:</div></td>
        <td class="style2"><input type="checkbox" name="chkcon" value="checkbox"></td>
      </tr>
      <tr>
        <td width="18%" class="style2"><div align="right">obsoleto:</div></td>
        <td class="style2"><input type="checkbox" name="chkobs" value="checkbox"></td>
      </tr>
      <tr>
        <td width="18%" class="style2"><div align="right">sottocategoria:</div></td>
        <td class="style2"><select name="select">
        </select>        </td>
      </tr>
      <tr>
        <td width="18%" class="style2"><div align="right">fornitore:</div></td>
        <td class="style2"><select name="select2">
        </select>        </td>
      </tr>
      <tr>
        <td width="18%" class="style2"><div align="right">targhetta:</div></td>
        <td class="style2"><input type="checkbox" name="chktar" value="checkbox"></td>
      </tr>
      <tr>
        <td width="18%" height="83" class="style2"><div align="right">descrizione:</div></td>
        <td class="style2"><textarea name="note6" cols="50" rows="5" width="300"></textarea></td>
      </tr>
      <tr>
        <td class="style2">&nbsp;</td>
        <td class="style2">
		  <input type="submit" name="btninsert" value="INSERISCI" onClick="this.form.action='insert_stanza'"/>
          <input type="submit" name="btninsert2" value="INDIETRO" onClick="this.form.action='gestione_stanze.jsp'"/></td>
		</tr>
    </form>
	</table>	</td>
  </tr>
  <tr>
    <td align="center" valign="middle">
    <%@page import = "java.sql.DriverManager"%>
<%@page import = "java.sql.ResultSet"%>
<%@page import = "java.sql.Statement"%>
<%@page import = "java.sql.SQLException"%>

<%! String oracleUser = "azienda";
	String oraclePwd  = "azienda";
	Connection conn;
	String driver;
	String oracle;
	String user;
	String matricola, codicefiscale, nome, cognome; 
	Statement st;
%>
<%
	user = session.getAttribute("user").toString().toLowerCase();
	driver = "oracle.jdbc.driver.OracleDriver";
	oracle = "jdbc:oracle:thin:@localhost:1521:xe"; 
	
	try {
		Class.forName(driver);
	} catch (ClassNotFoundException e) {
		e.printStackTrace();
	}
	
	try {
		conn = DriverManager.getConnection(oracle, oracleUser, oraclePwd);
		st = conn.createStatement();
	} catch (SQLException e) {
		e.printStackTrace();
	}
%>
    <%
    	String qry = "select count(*) as totale from stanza";
    	ResultSet rs = st.executeQuery(qry);
    	rs.next();
    	out.println("TOTALE RECORD: " + rs.getString("totale"));
    	
    	rs.close();
    	st.close();
    	conn.close();
    %>    </td>
  </tr>
</table>
</body>
</html>
